import request from '@/utils/request'

export function getTimeArray (params) {
  var data = fromData(params)
  return request({
    url: '/time_blue/getTimeArray',
    method: 'post',
    data
  })
}

export function getTimeInfo (params) {
  var data = fromData(params)
  return request({
    url: '/time_blue/getTimeInfo',
    method: 'post',
    data
  })
}

export function addTimeData (params) {
  var data = fromData(params)
  return request({
    url: '/time_blue/addTime',
    method: 'post',
    data
  })
}

export function editTimeData (params) {
  var data = fromData(params)
  return request({
    url: '/time_blue/editTime',
    method: 'post',
    data
  })
}

export function delTimeData (params) {
  var data = fromData(params)
  return request({
    url: '/time_blue/del_time',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
